<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="jquery-3.4.1.js"></script>
</head>
<style>
    #chicun{
        width: 100px;
        height: 100px;
        background-color: blue;
        border:1px solid black;
        padding:10px;
        margin: 20px;
    }
    #box1{
        width: 200px;
        height: 200px;
        border: 10px solid black;
        padding: 30px;
        margin: 40px;
        position: fixed;
    }
    #box2{
        width: 30px;
        height: 30px;
        background-color: red;
    }
    .box{
        width: 200px;
        height:200px;
    }
</style>
<body>
    <div id="box1">
        <div id="box2">
        </div>
    </div>
    <div id='chicun'></div>
    <button>按钮</button>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <script>
        //尺寸
        $('button').click(function(){
            console.log($('#chicun').width());//height() 只算width和height
            console.log($('#chicun').innerWidth());//innerHeight() 包含padding
            console.log($('#chicun').outerWideth());//outerHeight() 包含padding、border
            console.log($('#chicun').outerHeight(true));//outerWidth(ture) 包含padding、border、margin
        })
        //位置
        console.log($('#box2').offset())//获取元素相对于文档左侧和顶部的距离
        console.log($('#box2').position())//获取元素相对于带有定位的父级偏移坐标，父级没有定位就逐级往上找
        //滚动条
        $(window).scroll(function(){
            console.log($(document).scrollTop());//获取上下滚动位置
        })
    </script>
</body>
</html>